package Home;


import mylooks.greenteam.DatabaseHelper;
import mylooks.greenteam.R;
import mylooks.greenteam.Registration.User;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class ProfileFragment extends Fragment 
{
	public static DatabaseHelper dbH;
	public static User u;
	// onCreate
	@Override
	public void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
	}

	// onActivityCreated
	@Override
	public void onActivityCreated(Bundle savedInstanceState) 
	{
		super.onActivityCreated(savedInstanceState);
	}

	// onCreateView
	@SuppressWarnings("deprecation")
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
	{
		dbH=new DatabaseHelper(getActivity());
		u=dbH.GetUser();
		View layoutView = inflater.inflate(R.layout.home_profile, container, false);
		TextView txtname = (TextView) layoutView.findViewById(R.id.profile_name_value);
		txtname.setText(u.getName());	
		TextView txtdate = (TextView) layoutView.findViewById(R.id.profile_birthdate_value);
		txtdate.setText(String.valueOf(u.getBirthdate().getDay()) + "/"
					   +String.valueOf(u.getBirthdate().getMonth()) + "/"
					   +String.valueOf(u.getBirthdate().getYear()));
		ImageView img = (ImageView) layoutView.findViewById(R.id.img_gender);
		ImageView avatar = (ImageView) layoutView.findViewById(R.id.img_profile);
		avatar.setImageBitmap(u.getAvatar());
		if (u.getGender()=='M')
			img.setImageResource(R.drawable.male);
		else
			img.setImageResource(R.drawable.female);
		
		return layoutView;
	}			
	
}
